import { createStore, applyMiddleware, combineReducers, compose} from 'redux';
import thunkMiddleware from 'redux-thunk';
// import {createLogger} from 'redux-logger';

// createStore 是由redux提供的用来初始化store的函数， applyMiddleware是用来添加我们需要的中间件的。
// combineReducers 用来把多个reducers合并为一个单一实体。
// createLogger 就是我们这里唯一使用的一个中间件，可以console出每一个action后数据的详细处理过程，给调试带来了很大方便。

import Index from './modules/index'
import user from './modules/user'
import award from './modules/award'
import find from './modules/find'
import betcenter from './modules/betcenter'

const reducer = combineReducers({
  Index,
  user,
  award,
  find,
  betcenter
})
// const loggerMiddleware = createLogger(); // initialize logger

const createStoreWithMiddleware = applyMiddleware(thunkMiddleware)(createStore); // apply logger to redux

const configureStore = (initialState) =>compose(createStoreWithMiddleware(reducer, initialState)); 

export default configureStore;